package org.dlsu.mt.parser;

import java.util.Stack;

/**
 * The SemanticStack class is implemented to be able to
 * implement the cloning necessary for tthe GLRParserEngine
 * to work. The Objects stored in the semantic stack are
 * Symbols.
 */

public class SemanticStack extends Stack
{

	/**
	 * Constructs a semantic stack.
	 */

	public SemanticStack()
	{
		super();
	}

	/**
	 * Returns a clone of the stack. The elements within the stack are
	 * cloned and not merely referenced.
	 *
	 * @return the clone of this object
	 */

	public Object clone()
	{
		SemanticStack stack = new SemanticStack();

		for ( int i=0; i< this.size(); i++)
		{
			//System.out.println("Cloning Element "+i+" of "+this);
			stack.addElement(((Symbol)this.elementAt(i)).clone());
		}

		return stack;
	}
}